import 'package:flutter/material.dart';
import 'package:flutter_app/resources/pages/category_page.dart';
import 'package:flutter_app/resources/pages/dashboard_page.dart';
import 'package:flutter_app/resources/pages/download_page.dart';
import 'package:flutter_app/resources/pages/settings_page.dart';
import 'package:nylo_framework/nylo_framework.dart';

class NavigationNavigationHub extends NyStatefulWidget
    with BottomNavPageControls {
  static RouteView path = ("/navigation", (_) => NavigationNavigationHub());

  NavigationNavigationHub()
      : super(
            child: () => _NavigationNavigationHubState(),
            stateName: path.stateName());

  /// State actions
  static NavigationHubStateActions stateActions =
      NavigationHubStateActions(path.stateName());
}

class _NavigationNavigationHubState
    extends NavigationHub<NavigationNavigationHub> {
  /// Layouts:
  /// - [NavigationHubLayout.bottomNav] Bottom navigation
  /// - [NavigationHubLayout.topNav] Top navigation
  /// - [NavigationHubLayout.journey] Journey navigation
  NavigationHubLayout? layout = NavigationHubLayout.bottomNav(
      // backgroundColor: Colors.white,
      );

  /// Should the state be maintained
  @override
  bool get maintainState => false;

  /// Navigation pages
  _NavigationNavigationHubState()
      : super(() async {
          /// * Creating Navigation Tabs
          /// [Navigation Tabs] 'dart run nylo_framework:main make:stateful_widget home_tab,settings_tab'
          /// [Journey States] 'dart run nylo_framework:main make:journey_widget welcome_tab,users_dob,users_info --parent=Navigation'
          return {
            0: NavigationTab(
              title: "首页",
              page: DashboardPage(),
              icon: Icon(Icons.video_camera_front),
              activeIcon: Icon(Icons.video_camera_front, color: Colors.black),
            ),
            1: NavigationTab(
              title: "分类",
              page: CategoryPage(),
              icon: Icon(Icons.category_sharp),
              activeIcon: Icon(Icons.category_sharp, color: Colors.black),
            ),
            2: NavigationTab(
              title: "下载",
              page: DownloadPage(),
              icon: Icon(Icons.download_outlined),
              activeIcon: Icon(Icons.download_outlined, color: Colors.black),
            ),
            3: NavigationTab(
              title: "设置",
              page: SettingsPage(),
              icon: Icon(Icons.settings),
              activeIcon: Icon(Icons.settings, color: Colors.black),
            ),
          };
        });

  /// Handle the tap event
  @override
  onTap(int index) {
    super.onTap(index);
  }
}
